<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('更新操作列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>类型：</label>
                                <select name="sysmark">
                                    <option value="" name="sysmark">所有</option>
                                    <option value="1" name="sysmark">android</option>
                                    <option value="2" name="sysmark">ios</option>
                                </select>
                            </li>
                            <li>
                                <label>下载地址：</label>
                                <input type="text" name="address"/>
                            </li>
                            <li>
                                <label>提示内容：</label>
                                <input type="text" name="content"/>
                            </li>
                            <li>
                                <label>是否强制：</label>
                                <select name="force">
                                    <option value="" name="force">所有</option>
                                    <option value="1" name="force">是</option>
                                    <option value="2" name="force">否</option>
                                </select>
                            </li>
                            <li>
                                <label>版本号：</label>
                                <input type="text" name="version"/>
                            </li>
                            <li class="select-time">
                                <label >添加日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始日期" name="params[beginAddTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束日期" name="params[endAddTime]"/>
                            </li>
                            <li>
                                <label>项目类型：</label>
                                <select name="projectType">
                                    <option value="" name="projectType">所有</option>
                                    <option value="0" name="projectType">服务商</option>
                                    <option value="3" name="projectType">商户</option>
                                </select>
                            </li>
                            <li>
                                <label>市场类型：</label>
                                <input type="text" name="channel"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add(800,1100)" shiro:hasPermission="forceReplace:forceReplace:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-success single disabled" onclick="updatePack()" shiro:hasPermission="forceReplace:forceReplace:updatePack">
                    <i class="fa fa-edit"></i> 更新APK文件
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="forceReplace:forceReplace:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" ></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('forceReplace:forceReplace:edit')}]];
        var removeFlag = [[${@permission.hasPermi('forceReplace:forceReplace:remove')}]];
        var prefix = ctx + "forceReplace/forceReplace";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "更新操作",
                clickToSelect:true,
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                    {
                        field: 'projectType',
                        title: '项目类型',
                        formatter: function (value, row, index) {
                            if (row.projectType == 0 ){
                                return '<span style="color: green">服务商</span>';
                            } else if(row.projectType == 3){
                                return '<span style="color: blue">商户</span>';
                            } else {
                                return '<span style="color: red">未知</span>';
                            }
                        }
                    },
                {
                    field: 'sysmark',
                    title: '系统类型',
                    formatter: function (value, row, index) {
                        if (row.sysmark == 1 ){
                            return '<span style="color: blue">android</span>';
                        } else if(row.sysmark == 2 ){
                            return '<span style="color: green">ios</span>';
                        }
                    },
                },
                {
                    field: 'channel',
                    title: '市场类型'
                },
                {
                    field: 'version',
                    title: '版本号'
                },
                {
                    field: 'address',
                    title: '下载地址'
                },
                {
                    field: 'fileName',
                    title: '文件原名称'
                },
                {
                    field: 'content',
                    title: '更新内容'
                },
                {
                    field: 'note',
                    title: '上传结果'
                },
                {
                    field: 'force',
                    title: '强制状态',
                    formatter: function (value, row, index) {
                        if (row.force == 1 ){
                            return '<span style="color: green">是</span>';
                        } else if(row.force == 2 ){
                            return '<span style="color: blue">否</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    }
                },
                {
                    field: 'updatetime',
                    title: '修改时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\',800,1100)"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\',800,1100)"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /**
         * 更新包
         */
        function updatePack() {
            var id = $.table.selectColumns("id");
            $.modal.open("更新包",prefix + "/updatePack?id=" + id,'850','500');
        }


    </script>
</body>
</html>